package com.trkj.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import com.trkj.pojo.Permission;

public interface PermissionDAO extends JpaRepository<Permission,Integer>,JpaSpecificationExecutor<Permission> {
	/**
	 * 找到某个角色所拥有的功能
	 */
	@Query(nativeQuery = true, value = "SELECT f.per_id,f.per_name,f.per_funurl,f.per_menuurl,f.per_blockurl,(select 1 from `role-per` rp WHERE rp.role_id = ?1 and rp.per_id = f.per_id) v FROM permissions f")
	public List<Object[]> queryPermissionByRoleId(Integer roleid);
	/**
	 * 给角色分配权限
	 */
	/*@Query()
	public void giveMenuRolwPermission();*/
}
